#!/usr/bin/env python
# encoding: utf-8
# @author: Lin Han
# @contact: voldemort22@126.com
# @file: deprecated_app.py
# @time: 2021/5/7 16:22
# @desc:
from fastapi import APIRouter

from utils.mongo_tools import retrieve_all_mongo_values
from views.configs import *

factory_standard_router = APIRouter(
    prefix="/api/factory_standard",
    tags=["factory_standard"],
)


@factory_standard_router.get("/v1/factory_standard")
async def retrieve_by_name(name: str):
    """
    ## Retrieve Factory Standard data

    :param name:
    :return:
    """
    model = {"data": {}}
    try:
        model["data"] = retrieve_all_mongo_values(
            filter_conditions={"name": name},
            collection_name=FACTORY_STANDARD_COLLECTION,
        )[0]
        model["status"] = 1
    except:
        model["status"] = 0
    return model
